<?php
declare(strict_types=1);

namespace HyperfTest\Cases;

use \Hyperf\Testing\Client;
use PHPUnit\Framework\TestCase;

/**
 * @internal
 * @coversNothing
 */
class UserTest extends TestCase
{
    /**
     * @var Client
     */
    protected $client;

    protected $token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIyIiwiYXVkIjoiIiwiaWF0IjoxNTkwOTc5MzQ3LCJuYmYiOjE1OTA5NzkzNDcsImV4cCI6MTU5MTAwODE0NywidWlkIjoxLCJhY2NvdW50IjoibzgxejY0dUJ3M3VjdmgtVy1TNXlHM1d5TDVVdyJ9.DqnljxdfFE_LanZp_P7tlw1xmPjk-QQV7ktQRlnXaBg";

    public function __construct($name = null, array $data = [], $dataName = '')
    {
        parent::__construct($name, $data, $dataName);
        $this->client = make(Client::class);
    }

    public function testNoticeLis(){
        var_dump('测试后台统计接口-获取基本的访问数据');
        // /admin/wxvisit
        $uri = '/api/wxservice/get_list';
        $data = [];
        $res = $this->client->get($uri,$data,['authorization'=>'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIyIiwiYXVkIjoiIiwiaWF0IjoxNTkwOTc5MzQ3LCJuYmYiOjE1OTA5NzkzNDcsImV4cCI6MTU5MTAwODE0NywidWlkIjoxLCJhY2NvdW50IjoibzgxejY0dUJ3M3VjdmgtVy1TNXlHM1d5TDVVdyJ9.DqnljxdfFE_LanZp_P7tlw1xmPjk-QQV7ktQRlnXaBg']);
        $this->assertSame(0,$res['errCode']);
    }

    public function testNoticeList(){
        var_dump('测试小程序活动API-获取活动列表');
        $uri = '/api/wxservice/get_list';
        $data = [];
        $res = $this->client->get($uri,$data,['authorization'=>'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIyIiwiYXVkIjoiIiwiaWF0IjoxNTkwOTc5MzQ3LCJuYmYiOjE1OTA5NzkzNDcsImV4cCI6MTU5MTAwODE0NywidWlkIjoxLCJhY2NvdW50IjoibzgxejY0dUJ3M3VjdmgtVy1TNXlHM1d5TDVVdyJ9.DqnljxdfFE_LanZp_P7tlw1xmPjk-QQV7ktQRlnXaBg']);
        $this->assertSame(0,$res['errCode']);
    }

    public function testNotice(){
        var_dump('测试小程序活动API-获取活动');
        $uri = '/api/wxservice/form_msg';
        $data = [];
        $res = $this->client->get($uri,$data,['authorization'=>'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIyIiwiYXVkIjoiIiwiaWF0IjoxNTkwOTc5MzQ3LCJuYmYiOjE1OTA5NzkzNDcsImV4cCI6MTU5MTAwODE0NywidWlkIjoxLCJhY2NvdW50IjoibzgxejY0dUJ3M3VjdmgtVy1TNXlHM1d5TDVVdyJ9.DqnljxdfFE_LanZp_P7tlw1xmPjk-QQV7ktQRlnXaBg']);
        $this->assertSame(0,$res['errCode']);
    }

    public function testSign(){
        var_dump('测试小程序API-签到');
        $uri = '/api/wxuser/sign';
        $res = $this->client->get($uri,[],['authorization'=>$this->token]);
        $this->assertSame(0,$res['errCode']);
    }

    public function testSignCheck(){
        var_dump('测试小程序API-签到状态查询');
        $uri = '/api/wxuser/sign_check';
        $res = $this->client->get($uri,[],['authorization'=>$this->token]);
        $this->assertSame(0,$res['errCode']);
    }

    public function testRecord(){
        var_dump('测试小程序API-访问记录');
        $uri = '/api/wxuser/record';
        $data = ['type_explain'=>'/home/test'];
        $res = $this->client->get($uri,$data,['authorization'=>$this->token]);
        $this->assertSame(0,$res['errCode']);
    }

    public function testShare(){
        var_dump('测试小程序API-分享者openid查询');
        $uri = '/api/wxuser/share';
        $data = ['openid'=>'o81z64uBw3ucvh-W-S5yG3WyL5Uw'];
        $res = $this->client->get($uri,$data,['authorization'=>$this->token]);
        $this->assertSame(0,$res['errCode']);
    }

    public function testShareWithoutOpenid(){
        var_dump('测试小程序API-分享查自己的信息');
        $uri = '/api/wxuser/share';
        $data = [];
        $res = $this->client->get($uri,$data,['authorization'=>$this->token]);
        $this->assertSame(0,$res['errCode']);
    }

    public function testAddSmall(){
        var_dump('测试小程序API-添加小程序');
        $uri = '/api/wxuser/addsmall';
        $data = [];
        $res = $this->client->get($uri,$data,['authorization'=>$this->token]);
        $this->assertSame(0,$res['errCode']);
    }

    public function testFormMsgGet(){
        var_dump('测试小程序问题反馈API-获取问题信息');
        $uri = '/api/wxservice/form_msg';
        $data = [];
        $res = $this->client->get($uri,$data,['authorization'=>'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIyIiwiYXVkIjoiIiwiaWF0IjoxNTkwOTc5MzQ3LCJuYmYiOjE1OTA5NzkzNDcsImV4cCI6MTU5MTAwODE0NywidWlkIjoxLCJhY2NvdW50IjoibzgxejY0dUJ3M3VjdmgtVy1TNXlHM1d5TDVVdyJ9.DqnljxdfFE_LanZp_P7tlw1xmPjk-QQV7ktQRlnXaBg']);
        $this->assertSame(0,$res['errCode']);
    }

    public function testForm(){
        var_dump('测试小程序问题反馈API-post提交问题信息');
        $uri = '/api/wxservice/form_msg';
        $data = ['title'=>'ddd','mobile'=>'15512345678','detail'=>'dadadf','type'=>2];
        $res = $this->client->post($uri,$data,['authorization'=>'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIyIiwiYXVkIjoiIiwiaWF0IjoxNTkwOTc5MzQ3LCJuYmYiOjE1OTA5NzkzNDcsImV4cCI6MTU5MTAwODE0NywidWlkIjoxLCJhY2NvdW50IjoibzgxejY0dUJ3M3VjdmgtVy1TNXlHM1d5TDVVdyJ9.DqnljxdfFE_LanZp_P7tlw1xmPjk-QQV7ktQRlnXaBg']);
        $this->assertSame(0,$res['errCode']);
    }
}